package com.zoran.study.spring.controller.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import java.io.IOException;
import java.util.UUID;

/**
 * AuthCheckFilter
 *
 * @author zouxm
 * @date 2018/6/25
 */
@Slf4j
public class AuthCheckFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("check request auth...");
        servletRequest.setAttribute("userId", UUID.randomUUID());
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {

    }
}
